﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AirForceCDCTests.src.main
{
    public class Question
    {
        public string MainQuestion { get; protected set; }
        public List<string> Choices { get; protected set; }
        public int Answer { get; protected set; }
        public int Selected_Answer { get; set; }
        public int ID { get; set; }

        /// <summary>
        /// Constructor. Stores a question's information
        /// </summary>
        /// <param name="question">The question to be ask</param>
        /// <param name="choices">The possible choices to choose from</param>
        /// <param name="answer">The answer to the question</param>
        public Question(string question, List<string> choices, int answer) : this(question, choices, answer, -1) { }

        /// <summary>
        /// Constructor. Stores a question's information
        /// </summary>
        /// <param name="question">The question to be ask</param>
        /// <param name="choices">The possible choices to choose from</param>
        /// <param name="answer">The answer to the question</param>
        /// <param name="id">The questions ID</param>
        public Question(string question, List<string> choices, int answer, int id)
        {
            MainQuestion = question;
            Choices = choices;
            Answer = answer;
            ID = id;

            if (choices.Count > 4)
                MainWindow.DebugWindow.AddMessage("Too many choices are in the choice bank");

        }

        /// <summary>
        /// Human readable string to print out the question
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("Question ID: " + ID + "\n");
            builder.Append(MainQuestion + "\n");

            foreach (String s in Choices)
                builder.Append("\t" + s + "\n");

            builder.Append("Answer: " + Answer);

            if (Selected_Answer != 0 || Selected_Answer != null)
                builder.Append("\nSelected Answer: " + Selected_Answer + "\n");

            return builder.ToString();
        }
    }
}
